package newPan3d.content.lightScene
{
	import _Pan3D.display3D.Display3DSprite;
	import _Pan3D.display3D.analysis.AnalysisServer;
	import _Pan3D.texture.TextureManager;
	
	import _me.Scene_data;
	
	import flash.display3D.Context3D;
	import flash.display3D.Context3DProgramType;
	import flash.display3D.Context3DVertexBufferFormat;
	import flash.display3D.IndexBuffer3D;
	import flash.display3D.VertexBuffer3D;
	import flash.geom.Vector3D;
	
	public class LightDisplay3DSprite extends Display3DSprite
	{
		private var timeNum:Number=1;
		private var context3D:Context3D;
		private var vertexBuffer:VertexBuffer3D;
		private var indexBuffer:IndexBuffer3D; 
		public function LightDisplay3DSprite(context:Context3D)
		{
			super(context);
			context3D=context;
			makeMianpianModel();
		}
		override protected function setVa() : void {
			
			context3D.setTextureAt(1, _objData.texture);
			context3D.setVertexBufferAt(0, vertexBuffer, 0, Context3DVertexBufferFormat.FLOAT_3);
			context3D.setVertexBufferAt(1, vertexBuffer, 3, Context3DVertexBufferFormat.FLOAT_3);
			context3D.drawTriangles(indexBuffer, 0, -1);
		}
		private function makeMianpianModel() : void {
			
			var speed : Number = 100;
			var m: Number=1;
			vertexBuffer  = context3D.createVertexBuffer(4, 6);
			vertexBuffer.uploadFromVector(Vector.<Number>(
				[-speed,  0,speed, 0, 0, 1,
					speed, 0,speed, 1/m, 0, 1, 
					speed, 0,-speed, 1/m, 1/m, 1, 
					-speed,0,-speed,  0, 1/m, 1,]), 0, 4);
			var k : Array = [0, 2, 3, 0, 1, 2];
			indexBuffer  = context3D.createIndexBuffer(k.length);
			indexBuffer.uploadFromVector(Vector.<uint>(k), 0, k.length);
		}
		override protected function resetVa() : void {
			_context.setVertexBufferAt(0, null);
			_context.setVertexBufferAt(1, null);
			context3D.setTextureAt(1, null);
		}
		
		override protected function setVc() : void {
			this.updateMatrix();
			_context.setProgramConstantsFromMatrix(Context3DProgramType.VERTEX, 4, modelMatrix, true);

		}
	
	}
}